﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace FrogEngine
{
	public class RenderModelService : GameEntityServiceBase<IHasModel>, IRenderEntityService
	{
		public RenderModelService(IEngine engine)
			: base(engine)
		{
			this.graphicsDevice = engine.GraphicsDevice;
		}

		GraphicsDevice graphicsDevice;

		public void Render(GameTime gameTime)
		{
			graphicsDevice.Clear(Color.CornflowerBlue);
			graphicsDevice.BlendState = BlendState.Opaque;
			graphicsDevice.DepthStencilState = DepthStencilState.Default;
			graphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;

			foreach (var entity in SubscribedEntities)
				((IHasModel)entity).Render(gameTime);
		}
	}
}
